package com.game.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.http.HttpServletRequest;

public class BaseController {
    @Autowired
    private HttpServletRequest request;

    public IPage getPage(){
        String pageSize = (String) request.getAttribute("pageSize");
        String nowPage = (String) request.getAttribute("nowPage");
        if(StringUtils.isEmpty(pageSize) || StringUtils.isEmpty(nowPage)){
            return new Page<>(1, 10);
        }

        return new Page<>(Integer.valueOf(nowPage), Integer.valueOf(pageSize));
    }
}
